package servlet;

import component.Component;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by v on 17-5-23.
 */
@WebServlet(name = "AlterServlet",value = "/AlterServlet")
public class AlterServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int currentPage;

        try {
            currentPage=Integer.parseInt(req.getParameter("page"));
        }catch (Exception ex){
            currentPage=1;
        }

        String bar= Component.pageBar(currentPage);

        req.setAttribute("bar",bar);
        req.getRequestDispatcher("/alter/alter.jsp?page="+currentPage).forward(req,resp);
    }
}
